package messenger.domain;

import java.util.HashSet;
import java.util.Set;

public class ChatSession {
	private Set<User> userList;
	
	public ChatSession() {
		userList = new HashSet<User>();
	}
	
	public void addUser(User user) {
		userList.add(user);
	}
	
	public void removeUser(User user) {
		userList.remove(user);
	}
	
	public void notifyMessage(String message, User sendUser) {
		for (User user : userList) {
			if (!user.equals(sendUser)) {
				Message messageInstance = new Message(message, sendUser.getUniqueName());
				user.addMessage(messageInstance);
			}
		}	
	}
}
